package com.sunwayworld.basemodule.business.result.resource.impl;

import com.alibaba.fastjson.JSONObject;
import com.sunwayworld.basemodule.business.result.resource.LimsRunResource;
import com.sunwayworld.basemodule.business.result.service.LimsRunService;
import com.sunwayworld.basemodule.business.result.validators.RunAbnormalValidator;
import com.sunwayworld.basemodule.business.result.validators.RunSubmitAbleValidator;
import com.sunwayworld.framework.log.annotation.Log;
import com.sunwayworld.framework.log.annotation.LogModule;
import com.sunwayworld.framework.log.annotation.LogType;
import com.sunwayworld.framework.restful.data.RestJsonWrapperBean;
import com.sunwayworld.framework.spring.annotation.GikamBean;
import com.sunwayworld.framework.validator.data.annotation.ValidateDataWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

@LogModule("实验批次")
@RestController
@GikamBean
public class LimsRunResourceImpl implements LimsRunResource {

    @Autowired
    private LimsRunService limsRunService;

    @Override
    public LimsRunService getService() {
        return limsRunService;
    }

    @Log(value = "新增实验批次", type = LogType.INSERT)
    @Override
    @RequestMapping(method = RequestMethod.POST)
    public Long insert(RestJsonWrapperBean wrapper) {
        return getService().insert(wrapper);
    }

    @Log("结果录入提交")
    @Override
    @ValidateDataWith(RunSubmitAbleValidator.class)
    public void submit(RestJsonWrapperBean wrapperBean) {
        getService().submit(wrapperBean);
    }

    @Log("结果复核-审核通过")
    @Override
    public void passReview(RestJsonWrapperBean wrapperBean) {
        getService().passReview(wrapperBean);
    }

    @Log("结果复核-审核拒绝")
    @Override
    public void rejectReview(RestJsonWrapperBean wrapperBean) {
        getService().rejectReview(wrapperBean);
    }

    @Log("结果录入-暂停实验")
    @Override
    public void abnormal(RestJsonWrapperBean wrapperBean) {
        getService().abnormal(wrapperBean);
    }

    @Log("结果录入-暂停实验-校验分析项必填")
    @Override
    @ValidateDataWith(RunAbnormalValidator.class)
    public String check(RestJsonWrapperBean wrapperBean) {
        return "200";
    }

    @Log("实验异常中心-继续实验")
    @Override
    public void abnormalPass(RestJsonWrapperBean wrapperBean) {
        getService().abnormalPass(wrapperBean);
    }

    @Log("实验异常中心-终止实验")
    @Override
    public void abnormalStop(RestJsonWrapperBean wrapperBean) {
        getService().abnormalStop(wrapperBean);
    }

    @Log("结果录入移交")
    @Override
    public JSONObject resultEditHandOver(RestJsonWrapperBean wrapperBean) {
        return getService().resultEditHandOver(wrapperBean);
    }

    @Log("结果复核移交")
    @Override
    public JSONObject resultAuditHandOver(RestJsonWrapperBean wrapperBean) {
        return getService().resultAuditHandOver(wrapperBean);
    }
}
